<?php
/*
 * 获取的是酒店列表
 * 获取酒店详细信息
 */
class JiudianController extends ApiController
{
	public function actionMsg()
	{
//		$data = new ApiDatabase('CompanyHotel');
//		return $data->Data_interface_method(array(
//			'jiaotong'=>'traffic',
//			'jieshao'=>'desc',
//			'jiudianID'=>'id',
//			'jiudianImageList'=>'image',//
//			'jiudianName'=>'name',
//			'pingjia'=>'pingjia',
//			'price'=>'ticket',
//			'tel'=>'phone'
//		));
		$listID = isset($_GET['listID'])?$_GET['listID']:'';
		if ($listID == '' ||(!is_numeric($listID))){
			echo json_encode(array(
				'code'=>0,
				'msg'=>'所传的listID格式有误或者不纯在该值)'
			));die;
		}
		$sql = "SELECT * FROM news where cate_id = 21 and id = {$listID}";
		$model = new News();
		$profile = new CompanyHotel();
		$model = $model->findAllBySql($sql);
		$arraynew = array();
		$arraynew['code']=1;
		if (!empty($model)){
			foreach ($model as $value){
				$arr =array();
				$arr['jieshao'] = CHtml::value($value, 'description');
				$arr['jiudianID'] = CHtml::value($value, 'id');
				$arr['jiudianImageList'] = CHtml::value($value, 'cover');
				$arr['jiudianName'] = CHtml::value($value, 'title');
				$id = CHtml::value($value, 'id');
				$arraynew['data'][]= $arr;
			}
			$cri = new CDbCriteria();
			$cri->condition ='hotelid="'.$id.'"';
			$profile = $profile->findAll($cri);
			foreach ($profile as $va)
			{
				$arraynew['data']['jiaotong'] =CHtml::value($va, 'traffic');
				$arraynew['data']['pingjia'] =CHtml::value($va, 'pingjia');
				$arraynew['data']['price'] =CHtml::value($va, 'ticket');
				$arraynew['data']['tel'] =CHtml::value($va, 'phone');
			}
			echo json_encode($arraynew);
		}else {
			$array =array(
				'code'=>0,
				'msg'=>'该条数据不存在',
			);
			echo json_encode($array);
		}
	}
	public function actionList()
	{
		$listdata = new ApiDatabase('CompanyHotel');
		return $listdata->Data_interface_method(array(
			'jingdu'=>'jingdu',
			'jiudianID'=>'id',
			'jiudianName'=>'name',
			'weidu'=>'weidu',
		));
	}
}
